
APISERVERS=${1:-"https://apiserver.kube.cluster:16443"}

KUBE_SSL_DIR=/etc/kubernetes/ssl

# 设置集群参数
/opt/kubernetes/bin/kubectl config set-cluster kubernetes \
  --certificate-authority=${KUBE_SSL_DIR}/ca.pem \
  --embed-certs=true \
  --server=${APISERVERS}


# 设置客户端认证参数
/opt/kubernetes/bin/kubectl config set-credentials admin \
  --client-certificate=${KUBE_SSL_DIR}/admin.pem \
  --embed-certs=true \
  --client-key=${KUBE_SSL_DIR}/admin-key.pem


# 设置上下文参数
/opt/kubernetes/bin/kubectl config set-context kubernetes \
  --cluster=kubernetes \
  --user=admin


# 设置默认上下文
/opt/kubernetes/bin/kubectl config use-context kubernetes


echo -e "\033[42;37m==kubectl配置完成===============================================================================\033[0m"
